package com.yfqy.app.domain.mapper;

import com.yfqy.app.domain.entity.PromotionProduct;
import com.yfqy.app.modules.promotion.vo.PromotionProductVO;
import org.apache.ibatis.annotations.Param;

import java.util.List;
import java.util.Map;

public interface PromotionProductMapper {

    /**
     * 锁定的库存
     *
     * @param promotionId
     * @param skuNumbers
     * @return
     */
    int deductMultiStock(@Param("promotionId") Long promotionId, @Param("skuNumbers") Map<Long, Integer> skuNumbers);

    /**
     * 退回锁定的库存
     *
     * @param promotionId
     * @param skuNumbers
     * @return
     */
    int returnMultiStock(@Param("promotionId") Long promotionId, @Param("skuNumbers") Map<Long, Integer> skuNumbers);

    int insertBatch(@Param("promotionProducts") List<PromotionProduct> promotionProducts);

    List<PromotionProduct> selectByPromotionId(@Param("promotionId") Long promotionId);

    int batchUpdate(@Param("toUpdate") List<PromotionProduct> toUpdate);

    int batchDeleteByIds(@Param("toDelete") List<Long> toDelete);

    List<PromotionProductVO> selectPromotionProductsByPromotionIds(@Param("promotionIds") List<Long> promotionIds);

    PromotionProduct selectByPromotionIdAndSkuId(@Param("promotionId") Long promotionId, @Param("skuId") Long skuId);

    void releaseLockedStock(Map<Long, Integer> skuNumbers);
}